const fileService = require("../service/file");
//文件增
const fileAddController = async (ctx, next) => {
    const results = await fileService.fileAddService(ctx.request.body);
    if (results) {
        ctx.body = {
            code: 200,
            msg: "file add success"
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "file add error"
        }
    }
}
//文件查
const fileSelectController = async (ctx, next) => {
    const results = await fileService.fileselectService();
    if (results) {
        ctx.body = {
            code: 200,
            msg: "file select success",
            data: results
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "file select error"
        }
    }
}
//文件删
const fileDeleteController = async (ctx, next) => {
    // console.log(ctx.params,'params')
    // console.log(ctx.query,'query')
    const results = await fileService.filedeleteService(ctx.query.id);
    if (results) {
        ctx.body = {
            code: 200,
            msg: "file delete success",
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "file delete error"
        }
    }


}
//文件改
const fileUpdataController = async (ctx, next) => {
    // console.log(ctx.params,'params')
    // console.log(ctx.query,'query')
    const results = await fileService.fileupdataService(ctx.request.body);
    if (results) {
        ctx.body = {
            code: 200,
            msg: "file updata success",
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "file updata error"
        }
    }


}
module.exports = {
    fileAddController,
    fileSelectController,
    fileDeleteController,
    fileUpdataController,
}